<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录 - 跨屏朋友圈</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="shortcut icon" href="/images/favicon.ico" />
    <link rel="stylesheet" href="/dashboard/css/bootstrap.min.css">
    <link rel="stylesheet" href="/dashboard/css/font-awesome.min.css">
    <link rel="stylesheet" href="/dashboard/css/AdminLTE.min.css">
    <style>
        .login-page{ color:#fff; background:url(/dashboard/images/sign-in.jpg); background-size:cover}
        .log-area{ margin-top:30px}
        p.pull-right{ margin-bottom:0}
        .nav-tabs-custom{ background:rgba(255,255,255,0.15)}
        .login-logo img{ max-height:100px}

        a{ color:#f26236}
        a:hover{ color:#FF5809}
        .btn-primary{ background-color:#f26236; border-color:#f26236}
        .btn-primary:hover{ background-color:#FF5809; border-color:#FF5809}
        .login-box-title{text-align: center; margin: 5% 0}
    </style>
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#"><b><img src="/dashboard/images/sign-in-logo.png" /></b></a>
    </div>
    <div class="login-box-title" >
        <h3>免费试用申请</h3>
    </div>
    <div class="nav-tabs-custom">
        <div class="tab-content">
            <!--apply-->
            <div class="login-box-body tab-pane active"  id="apply">
                <p class="login-box-msg text-bold" id="singup_err"></p>
                <!--<form  id="singup_form">-->
                    <input type="hidden" value="<%= security_code %>" name="security_code" />
                    <div class="form-group has-feedback">
                        <input type="text" class="form-control" name="name" value='' placeholder="姓名">
                        <span class="fa fa-user form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <input type="email" class="form-control" name="email"  placeholder="邮箱" id="email">
                        <span class="fa fa-envelope form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <input type="text" class="form-control" name="company" placeholder="公司名称">
                        <span class="fa fa-edit (alias) form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <input type="tel" class="form-control" name="telephone" placeholder="联系电话">
                        <span class="fa fa-mobile form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <input type="text" class="form-control" name="industry" placeholder="所属行业">
                        <span class="fa fa-edit (alias)  form-control-feedback"></span>
                    </div>
                    <div class="clearfix"></div>
                    <div class="row log-area">
                        <div class="col-xs-12">
                            <button  class="btn btn-primary btn-block btn-flat" id="submit_request">申请提交</button>
                        </div>
                    </div>
                <!--</form>-->
            </div>
        </div>
    </div>
</div>

<script src="/dashboard/js/jQuery-2.1.4.min.js"></script>
<script src="/dashboard/js/bootstrap.min.js"></script>
<script>
    $(function(){
        $('#submit_request').click(function(){
            function check(){
                var errorMsg=null;

                if( !$.trim($("input[name='name']").val()) ){
                    return errorMsg = {msg:'用户名不能为空',target:'name'}
                }

                if( !$.trim($("input[name='email']").val() )){
                    return errorMsg = {msg:'邮箱不能为空',target:'email'}
                }else if( $.trim($('#email').val())!="" && !/.+@.+\.[a-zA-Z]{2,4}$/.test($('#email').val()) ){
                    return errorMsg = {msg:'请输入正确的邮箱地址',target:'email'}
                }

                if( !$.trim($("input[name='company']").val()) ){
                    return errorMsg = {msg:'公司名称不能为空',target:'company'}
                }

                if( !$.trim($("input[name='telephone']").val()) ){
                    return errorMsg = {msg:'联系电话不能为空',target:'telephone'}
                }

                return errorMsg
            }

            var err=check();

            if(err){
                $('#singup_err').html(err.msg);
                return false;
            } else {
                var name = $("input[name='name']").val();
                var email = $("input[name='email']").val();
                var company = $("input[name='company']").val();
                var telephone = $("input[name='telephone']").val();
                var industry = $("input[name='industry']").val();
                $.ajax({
                    type: "post",
                    url:'/request-a-demo',
                    dataType: 'json',
                    data: {
                        name: name,
                        email: email,
                        company: company,
                        telephone: telephone,
                        industry: industry
                    },
                    success: function(data){
                        if(data.success) {
                            $(".login-box-title").hide();
                            $(".nav-tabs-custom").html('<div style="text-align: center; font-size: 18px;padding: 15px 0px">您的申请已经提交</div>'
                                                      +'<div style="text-align: center; font-size: 18px;padding-bottom: 15px">我们的售前专家会在第一时间联系您！</div>'
                                                      +'<div style="text-align: center; font-size: 18px;padding-bottom: 15px">感谢您对我们产品的关注</div>'
                                                      +'<div style="text-align: center;"></div>'
                                                      +'<div style="text-align: center;padding-bottom: 15px">联系邮件<a href="mailto:hi@parllay.cn" style="display: inline-block;margin-right: 10px">hi@parllay.cn</a>柏丽互赢 <a href="www.parllay.cn">www.parllay.cn</a></div>');
                        } else {
                            $(".nav-tabs-custom").html('<div style="text-align: center; font-size: 18px; padding: 20px">申请失败，请重新填写</div>');
                        }
                    },
                    error: function(error){
                        console.log(error);
                    }
                })
            }
        })
    })
</script>
<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    ga('create', 'UA-46105991-4', 'auto');
    ga('send', 'pageview')
</script>
</body>
</html>
